const app = getApp();
Component({
  data: {
    selected: null,
    color: "#a0a0a0",
    selectedColor: "#5287eb",
    canCustom: true,
    list: [] //tabBar的数据
  },
  lifetimes: {
    //组件的生命周期函数
    created: function() {
      console.log("created");
    },
    attached() {
      var that = this;
      console.log("attached");
      var tabBar = wx.getStorageSync("tabBar");
      that.setData({
        list: tabBar
      });
    },
  },
  pageLifetimes: {
    show: function() {
      // 页面被展示
      console.log("show");
    }
  },
  methods: {
    switchTab(e) {
      console.log("switchTab");
      const data = e.currentTarget.dataset
      const url = data.path

      var tabBar = wx.getStorageSync("tabBar");
      this.setData({
        list: tabBar
      })

      wx.switchTab({
        url
      })
      this.setData({
        selected: data.index
      })
    }
  }
})